<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

//定义接口路由
$api = app(\Dingo\Api\Routing\Router::class);

$api->version('v1',['namespace'=>'App\Http\Controllers\Api'],function ($api) {
    //$api->get('version', function () {
    //    return 'v1';
    //});
    //获取轮播图接口
    $api->get('slider','SliderController@slider');
    //获取所有文章接口
    $api->get('articles','ArticleController@articles');
    //获取推荐文章接口
    $api->get('article','ArticleController@hotArticle');
    //获取单个文章接口
    $api->get('article/{id}','ArticleController@article');
    //获取所有分类数据接口
    $api->get('categorys','CategoryController@categorys');
    //小程序登录接口
    $api->post('login','AuthController@login');
    //小程序退出登录接口
    $api->get('loginout','AuthController@logout');
    //获取已经登录的用户信息接口
    $api->get('me','AuthController@me');
});

